<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    //82.67%
    var sumEvenAfterQueries = function(A, queries) {
        let s = 0;
        for(let i in A){
            if(A[i]%2 == 0){
                s += A[i];
            }
        }
        let arr = [];
        for(let j in queries){
            let val = queries[j][0], index = queries[j][1];
            if(A[index]%2 == 0)s -= A[index];
            A[index] += val;
            if(A[index]%2 == 0)s += A[index];
            arr.push(s);
        }
        return arr;
    };
    let  A = [1,2,3,4], queries = [[1,0],[-3,1],[-4,0],[2,3]];
    console.log(sumEvenAfterQueries(A, queries));
    
</script>
</html>